package org.cangku.controller;

import org.cangku.dao.TiChengDao;
import org.cangku.dao.XiaoShouDao;
import org.cangku.entity.Xiaoshou;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/ticheng")
public class TiChengController {
    @Autowired
    private TiChengDao tiChengDao;
    @Autowired
    private XiaoShouDao xiaoShouDao;

    @RequestMapping("/query")
    @ResponseBody
    public Map<String,Object> query(String name,int offset,int limit){
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("rows",tiChengDao.query(name,offset,limit));
        map.put("total",tiChengDao.count(name));
        return map;
    }
    @RequestMapping("/getxiaoshou")
    @ResponseBody
    public List<Xiaoshou> getinfo(int yid){
        return xiaoShouDao.getXSinfo(yid);
    }
}
